<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
?>
<?php
/* 
	[BuyPg] (C) 2010-2011 Buypg
	$Id: WebpingAction.class.php 2011-4-26 10:32:43 wufujun $
 */

if (!defined('THINK_PATH')){
	exit('Access Denied');
}

class GuowaiAction extends BpAction{
	
	public function index(){
		global $_SGLOBAL;
		$pgsys = $this->PublicPgsys;
		//网站系统相关设置在当前控制器私有设置
		$pgsys['sys_set']['set_footer_tools'] = 1; //网站页脚 ”常用工具“ 显示
                $arrISite = getISiteMainCache();
                $arrClass = getLeftCategory_nbclass();
		//模板输出
		$this->assign('leftcate_guowai' , $arrClass);
                $this->assign('guowaiclass',$arrISite);
		$this->display();
	}
        

	public function guowailist(){
		global $_SGLOBAL;
		//继承初始网站系统相关信息
		$pgsys = $this->PublicPgsys;
                if(empty ($_GET['classid']))
                {
                    $this->error('您查看的信息不存在或已经删除');
                }
		$classid = empty($_GET['classid']) ? 0 : intval($_GET['classid']) ;
		//默认以f1--网站易用排行
		$o = 'f1';
		if($classid){
			$DbSite = M('NbClass');
                        $sWhere = " class_id = $classid and country_id = 1 and flag = 1 ";
			$arrClass = $DbSite->where("class_id = $classid")->find();
			$DbSite = M('NbSite');
			import("@.ORG.Page"); //导入分页类
			$count = $DbSite->where($sWhere)->count();    //计算总数
			$p = new Page ( $count, 20 );
			$arrSite = $DbSite->where($sWhere)->limit($p->firstRow.','.$p->listRows)->order("$o DESC")->select();

			$p->setConfig('header','篇记录');
			$p->setConfig('prev','<');
			$p->setConfig('next','>');
			$p->setConfig('first','<<');
			$p->setConfig('last','>>');

			$p->setConfig('theme', ' <span>%totalRow% %header% %nowPage%/%totalPage% 页 </span> %first% %upPage% %linkPage% %downPage% %end%');
			$page = $p->show(1);
			if($arrSite){
				//格式化数据
				foreach ($arrSite as $key=>$value){
					$arrSite[$key]['site_link'] = urldecode($value['site_link']);
					$arrSite[$key]['f1'] = formatFen($value['f1']);
					$arrSite[$key]['f2'] = formatFen($value['f2']);
					$arrSite[$key]['f3'] = formatFen($value['f3']);
					$arrSite[$key]['f4'] = formatFen($value['f4']);
					$arrSite[$key]['f5'] = formatFen($value['f5']);
					$arrSite[$key]['f6'] = formatFen($value['f6']);
					$arrSite[$key]['f7'] = formatFen($value['f7']);
				}
				$list = $arrSite;
			}else{
				$this->error('您查看的信息不存在或已经删除');
			}
		}else{
			$this->error('您查看的信息不存在或已经删除');
		}
		//定义左侧分类
                $LeftCate = getLeftCategory_nbclass();

		//模板输出
		//$this->assign('o' , $o);
		$this->assign('leftcate_guowai' , $LeftCate);
		//$this->assign('descmenu' , $pgsys['sys_webping_desc']); //排序菜单
		$this->assign('classinfo' , $arrClass);
		$this->assign('guowai_list' , $list);
		$this->assign('page' , $page);
		$this->display();
	}
        
}
?>
